/*
  S.M.A.C.K - An operating system kernel
  Copyright (C) 2010,2011 Mattias Holm and Kristian Rietveld
  For licensing and a full list of authors of the kernel, see the files
  COPYING and AUTHORS.
*/
/*
 * Based on code that is
 * Copyright 2006,2010 Mattias Holm <mattias.holm(at)openorbit.org>
 */

#ifndef __HEAP_H__
#define __HEAP_H__

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>

#define HEAP_SIZE 128

struct heap_entry_t {
    uint32_t deadline;
    void *entry;
};

struct heap_t {
    int last;
    size_t size;
    struct heap_entry_t elements[HEAP_SIZE];
};

void heap_init(struct heap_t *h);
bool heap_insert(struct heap_t *h, void *entry, uint32_t deadline);
void heap_remove(struct heap_t *h);
void *heap_peek(struct heap_t *h);
unsigned int heap_peek_rank(struct heap_t *h);

#endif
